package com.smallkingson.ylib.core.utils;

import com.smallkingson.ylib.core.Yr;

public class YTimeTests {

    public static YTimeTest DEFAULT = new YTimeTest();

    public static void test() {
        test(null);
    }

    public static void test(String log) {
        DEFAULT.test(log);
    }

    public static void print() {
        DEFAULT.print();
    }

    public static void testTime(Runnable runnable) {
        testTime(null, runnable);
    }

    public static void testTime(String tag, Runnable runnable) {
        long start = System.currentTimeMillis();
        try {
            runnable.run();
        } catch (Exception e) {
            Yr.logError(e);
        }
        long end = System.currentTimeMillis();
        Yr.log(Yr.LOG_LEVEL_D, new Throwable().getStackTrace()[1], tag, "耗时：" + (end - start) + "ms");
    }

    public static interface Runnable {
        void run() throws Exception;
    }
}
